fix clazy detected 'c++11 range-loop might detach Qt container'
authortsteven4 <tsteven4@gmail.com>
Mon, 12 Nov 2018 16:13:28 +0000 (09:13 -0700)
committertsteven4 <tsteven4@gmail.com>
Mon, 12 Nov 2018 16:13:28 +0000 (09:13 -0700)
these are from -Wclazy-range-loop

csv_util.cc
gpx.cc

index af70bfa5b6095cf02dc3c8fe6d3f3c5b04019ec2..034e34a34b2a3f460e31c72a87687c728aeb08c6 100644 (file)
@@ -1593,7 +1593,7 @@ xcsv_waypt_pr(const Waypoint* wpt)
   }
 
   int i = 0;
-  for (const auto& fmp : xcsv_file.ofields) {
+  for (const auto& fmp : qAsConst(xcsv_file.ofields)) {
     double lat = latitude;
     double lon = longitude;
     /*
@@ -2183,7 +2183,7 @@ xcsv_data_write(void)
   waypt_out_count = 0;
 
   /* output prologue lines, if any. */
-  for (const auto& line : xcsv_file.prologue) {
+  for (const auto& line : qAsConst(xcsv_file.prologue)) {
    QString line_to_write = xcsv_replace_tokens(line);
     *xcsv_file.stream << line_to_write <<  xcsv_file.record_delimiter;
   }
@@ -2199,7 +2199,7 @@ xcsv_data_write(void)
   }
 
   /* output epilogue lines, if any. */
-  for (const auto& line : xcsv_file.epilogue) {
+  for (const auto& line : qAsConst(xcsv_file.epilogue)) {
     QString line_to_write = xcsv_replace_tokens(line);
     *xcsv_file.stream << line_to_write << xcsv_file.record_delimiter;
   }
diff --git a/gpx.cc b/gpx.cc
index f0ee94ab1986228321a9eb4bed2bcfd7dd569ced..43606dde01e929c49c8c9dab21f0c7db0f8a4ce3 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
  */
 
 #include "defs.h"
-#include "cet_util.h"
 #include "garmin_fs.h"
 #include "garmin_tables.h"
+#include "src/core/datetime.h"
 #include "src/core/file.h"
 #include "src/core/logging.h"
 #include "src/core/xmlstreamwriter.h"
 #include "src/core/xmltag.h"
 
-#include <QtCore/QDateTime>
-#include <QtCore/QDebug>
-#include <QtCore/QRegExp>
-#include <QtCore/QXmlStreamReader>
+#include <QtCore/QDateTime>            // for QDateTime, QDate, QTime
+#include <QtCore/QHash>                // for QHash
+#include <QtCore/QList>                // for QList
+#include <QtCore/QString>              // for QString, QStringLiteral, QStringRef, QStaticStringData, QLatin1String, operator+
+#include <QtCore/QStringList>          // for QStringList
+#include <QtCore/QXmlStreamAttributes> // for QXmlStreamAttributes
+#include <QtCore/QXmlStreamNamespaceDeclarations> // for QXmlStreamNamespaceDeclarations
+#include <QtCore/QXmlStreamReader>     // for QXmlStreamReader, QXmlStreamReader::TokenType::Characters, QXmlStreamReader::TokenType::EndDocument, QXmlStreamReader::TokenType::EndElement, QXmlStreamReader::TokenType::Invalid, QXmlStreamReader::TokenType::StartElement
+#include <QtCore/QtGlobal>             // for qAsConst
 
-#include <cmath>
+#include <cmath>                       // for lround
+#include <cstdio>                      // for sscanf
+#include <cstdlib>                     // for atoi, strtod
+#include <cstring>                     // for strchr
 
 
 static QXmlStreamReader* reader;
@@ -1302,7 +1310,7 @@ gpx_wr_init(const QString& fname)
   } else {
     if (gpx_global) {
       // TODO: gpx 1.1 copyright goes here
-      for (const auto& l : gpx_global->link) {
+      for (const auto& l : qAsConst(gpx_global->link)) {
         writer->writeStartElement(QStringLiteral("link"));
         writer->writeAttribute(QStringLiteral("href"), l.url_);
         writer->writeOptionalTextElement(QStringLiteral("text"), l.url_link_text_);